<template>
  <a-modal
    :visible="visible"
    :confirm-loading="loading"
    @ok="() => { $emit('ok', model) }"
    @cancel="() => { $emit('cancel', model) }"
  >
    <p>{{ ModalText }}</p>
  </a-modal>
</template>

<script>

  export default {
    name: 'DeleteModal',
    props: {
      visible: {
        type: Boolean,
        required: true
      },
      loading: {
        type: Boolean,
        default: () => false
      },
      model: {
        type: Object,
        default: () => null
      }
    },
    data () {
      return {
        ModalText: "确认删除？"
      };
    },
    methods: {},
    created () {
      // 防止表单未注册
      // fields.forEach(v => this.form.getFieldDecorator(v))

      // 当 model 发生改变时，为表单设置值
      this.$watch('model', () => {
        if (this.model && this.model.name) {
          this.ModalText = `确认删除 ${this.model.name}？`
        }
      })
    }
  }
</script>

<style scoped>

</style>
